/*
 *
 * Copyright (C) 2008 Jose Javier García Zornoza.
 * 
 * Este es un programa libre; puedes distribuirlo y/o modificarlo bajo
 * los términos de la versión 2 (o cualquier versión posterior) de la Licencia 
 * Pública General de la Fundación de Software Libre.
 * Este programa se distribuye con la esperanza  de poder ser útil, pero sin
 * NINGUNA GARANTIA; tampoco la garantía implícita de COMERCIALIZACION o DEDICACIÓN
 * A UN PROPOSITO PARTICULAR. Ver la licencia GNU GPL para más detalles.
 * Deberías haber recibido una copia de la licencia GNU GPL con este programa;
 * en caso contrario puedes obtener una copia visitando el sitio web www.fsf.org
 * o escribiendo a la Fundación de Software Libre, Inc., 59 Temple 
 * Place - Suite 330, Boston, MA  02111-1307, USA. 
 *
 */
package org.gruposp2p.dnie.ui.dialogs;

import dniegp2pclient.DNIeGP2PClientApp;
import org.jdesktop.application.Application;
import org.jdesktop.application.ResourceMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class ErrorDialog extends javax.swing.JDialog {

    private static Logger logger = LoggerFactory.getLogger(ErrorDialog.class);

    private ResourceMap resourceMap;

    /** Creates new form ErrorDialog */
    public ErrorDialog(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        this.setLocationRelativeTo(parent);
        initComponents();
        resourceMap = Application.getInstance(DNIeGP2PClientApp.class)
                .getContext().getResourceMap(DocumentAlreadySendedDialog.class);
        setTitle(resourceMap.getString("dialogTitle.text"));
        setSize(400, 300);
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        errorPane = new javax.swing.JEditorPane();
        acceptButton = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setName("Form"); // NOI18N

        jScrollPane1.setName("jScrollPane1"); // NOI18N

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance().getContext().getResourceMap(ErrorDialog.class);
        errorPane.setBackground(resourceMap.getColor("errorPane.background")); // NOI18N
        errorPane.setName("errorPane"); // NOI18N
        jScrollPane1.setViewportView(errorPane);

        acceptButton.setIcon(resourceMap.getIcon("acceptButton.icon")); // NOI18N
        acceptButton.setText(resourceMap.getString("acceptButton.text")); // NOI18N
        acceptButton.setName("acceptButton"); // NOI18N
        acceptButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                aceptarHandler(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(acceptButton))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 247, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(acceptButton)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void aceptarHandler(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_aceptarHandler
        this.dispose();
    }//GEN-LAST:event_aceptarHandler

    public void setErrorMessage (String error) {
        errorPane.setText(error);
        errorPane.updateUI();
        setVisible(true);
    }
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton acceptButton;
    private javax.swing.JEditorPane errorPane;
    private javax.swing.JScrollPane jScrollPane1;
    // End of variables declaration//GEN-END:variables
    
}
